package demo1;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Auther: 杨通通
 * @Date: 2024/9/10 23:57
 * @Description:
 */
public class Stream2 {

    public static void main(String[] args) {
        List<Person> list1 = new ArrayList<>();
        List<Person> list2 = new ArrayList<>();
        list1.add(new Person("A",23));
        list1.add(new Person("B",23));
        list2.add(new Person("C",23));
        list2.add(new Person("D",23));
        List<List<Person>> listPlus = new ArrayList<>();
        listPlus.add(list1);
        listPlus.add(list2);
        List<String> nameList = listPlus.stream()
                .flatMap(t -> t.stream()) //此时流中元素为Person对象
                .map(t -> t.getName())
                .distinct()
                .collect(Collectors.toList());
//A B C D

    }
}